<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DOM元素节点变量</title>
</head>
<body>
    <div>第一个DIV</div>
    <ul>
        <li>列表项1</li>
        <li>列表项2</li>
        <li>列表项3</li>
    </ul>
    <script>
       for(let elem of document.body.children) {
            console.log(elem);
       }
       console.log("第一个子节点");
       console.log(document.body.firstElementChild);
       console.log("最后一个子节点");
       console.log(document.body.lastElementChild);
       console.log("得到父节点");
       console.log(document.body.parentElement);
       console.log("前一个兄弟节点");
       console.log(document.body.children[1].previousElementSibling);
       console.log("后一个兄弟节点");
       console.log(document.body.children[1].nextElementSibling);
       console.log("second li");
       console.log(document.body.children[1].children[1]);
    </script>
</body>
</html>